home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 476-500 / disk_477 / irmaster / ircserver.asm < prev    next >
Assembly Source File  |  1992-05-06  |  5KB  |  151 lines

  1. ;
  2. ;  ircserver.asm
  3. ;
  4. ;  This Lattice V5.04 assembly language routine gets added to the
  5. ;  level 2 interrupt server chain to deal with INT2 interrupts
  6. ;  caused by bringing the ACK pin on the parallel port low.
  7. ;
  8. ;
  9. ;  NOTE: Lattice asm doesn't like: move.l _irc, a1
  10. ;          and DOES like: move.l _irc,a1
  11. ;          Only difference is the space before "a1".
  12. ; Also, calling an external Lattice C routine from assembly must be
  13. ; done after the Enable(), Permit().  (Would probably work before
  14. ; the Forbid(), Disable() too.)
  15. ; To pass a variable which is a pointer to a C function use:
  16. ;
  17. ;          [struct Interrupt *SoftInterrupt; Cause(SoftInterrupt);]
  18. ;
  19. ;        move.l     _SoftInterrupt,a1   ; Put address of Interrupt structure
  20. ;        move.l     a1,-(a7)            ; onto stack.
  21. ;        JSR       _Cause
  22. ;        ADDQ      #4,A7                ; Fix the stack pointer.
  23. ;
  24. ; To pass a variable which is NOT a pointer AS a pointer to a C function use:
  25. ;
  26. ;          [struct Interrupt SoftInterrupt; Cause(&SoftInterrupt);]
  27. ;
  28. ;        LEA       _SoftInterrupt,A1
  29. ;        MOVE.L    A1,-(A7)
  30. ;        JSR       _Cause
  31. ;        ADDQ      #4,A7                ; Fix the stack pointer.
  32. ;
  33. ;
  34. ;
  35.         csect data,1,,2,2
  36.         xref _LVOSignal
  37.  
  38.         csect text
  39.  
  40.     xdef _ircserver
  41.  
  42.         xref _ciab
  43.         xref _SoftInterrupt
  44.         xref _thisTask
  45.         xref _TimerSigMask
  46.         xref _buffer
  47.         xref _NSamples
  48.  
  49.         xref _Forbid
  50.         xref _Disable
  51.         xref _Enable
  52.         xref _Permit
  53.  
  54.         xref _custom
  55.  
  56. data1             equ   $bfe101
  57. dir1              equ   $bfe301
  58.  
  59. _ircserver
  60. ;
  61. ; Save registers on stack.
  62. ;
  63.         MOVEM.L A2-A6/D2-D7,-(SP)  ;  Push Registers 
  64. ;
  65. ; Disable interrupts and tasking.
  66. ;
  67.         JSR       _Forbid  ; RKM says this is a no-no but don't work without it.
  68.         JSR       _Disable
  69. ; Machine is MINE now until I let it go!
  70. ;
  71. ;
  72. ;  Read from parallel port to see if IR hardware triggered this interrupt.
  73. ;  If not then let the server chain continue without further ado.
  74. ;
  75. ;
  76. ; Set up parallel port for reading.
  77. ;
  78.       move.b   #0,dir1           * all lines read
  79.       move.b   #0,data1
  80.       move.b   data1,d0       ; Move byte from parallel port to register.
  81.       andi.b   #$01,d0        ; Mask off bit 0.
  82.       beq      proceed        ; If bit is one, then proceed to capture data.
  83.  
  84.       JSR       _Enable
  85.       JSR       _Permit  ; RKM says this is a no-no but don't work without it.
  86.       MOVEM.L (SP)+,A2-A6/D2-D7  ;  Pop Registers
  87.       MOVEQ     #$00,D0          ; Continue the server chain.
  88.       RTS
  89. ;
  90. ; Disable the ACK interrupt until after processing is done.
  91. ; (Is re-enabled in irc.c)
  92. ; Hex 10 = 00010000 Should disable the 8520 FLAG interrupt.
  93. ;
  94. proceed:   move.b  #$10,$BFED01
  95. ;
  96. ; Turn off the display so that DMA access for screen update doesn't
  97. ; steal cycles from the 68000 processor.
  98. ;  $0100 = clear BPLEN bit; custom+$96 = dmacon register
  99. ;
  100.            move.w #$100,$96+_custom
  101. ;
  102. ; Start timer B.
  103. ;
  104.         lea.l _ciab,a1      ; Get address of ciab
  105.         adda.l  #$F00,a1    ; Add offset for ciacrb register.
  106.         or.b #$01,(a1)      ; $01 = CIACRBF_START ---> Starts timer b!
  107. ;
  108. ; Read data from parallel port until buffer is full.
  109. ;
  110. hold: move.b    $bfdd00,d0  ; Read 8520 IRC register to get/reset interrupt bit
  111.       andi.l    #$02,d0     ; Mask off timer B interrupt bit.
  112.       beq       hold        ; Loop till get an interrupt.
  113. ;
  114. ; Read a byte from 8250-A (parallel port)  The data direction registers are
  115. ; set up in SoftHandler.
  116. ;
  117.       movea.l  _buffer,a1        ; a1 now holds buffer location
  118.       move.b   data1,(a1)+       ; Move byte from parallel port to buffer.
  119.       move.l   a1,_buffer        ; Update pointer to buffer.
  120.       subq.l   #$1,_NSamples     ; 8
  121.       bne      hold              ; Go wait for next timeout if buffer not full.
  122.  
  123.       move.b #$02,$BFDD00   ; Disable timer B interrupts.
  124.       move.b    $bfdd00,d0  ; Read 8520 IRC register to reset interrupt bit.
  125. ;
  126. ; Turn on the display (enable bitplane DMA).
  127. ;  $8100 = set BPLEN bit; custom+$96 = dmacon register
  128. ;
  129.            move.w #$8100,_custom+$96
  130. ;
  131. ; Enable interrupts and tasking.
  132. ;
  133.         JSR       _Enable
  134.         JSR       _Permit  ; RKM says this is a no-no but don't work without it.
  135. ;
  136. ; Signal main task to wake up.  Data is ready!
  137. ;
  138.       move.l    _TimerSigMask,d0     ; Set up data in registers.
  139.       movea.l    _thisTask,a1
  140.       movea.l   $4,a6
  141.       jsr       _LVOSignal(a6)       ; Send signal (see note above.)
  142. ;
  143. ;
  144. ; Clean up, restore registers and return.
  145. ;
  146.         MOVEM.L (SP)+,A2-A6/D2-D7  ;  Pop Registers
  147.         MOVEQ     #$00,D0          ; Continue the server chain.
  148.         RTS
  149.  
  150.         END
  151.